package sort;

import java.util.Arrays;

/**
 * Created by Administrator on 2018/2/24 0024.
 */
public class InsertSort
{
    public static void main(String[] args)
    {
        int[] NUMBERS = {49, 38, 65, 97, 76, 13, 27, 78, 34, 12, 64, 5, 4, 62, 99, 98, 54, 56, 17, 18, 23, 34, 15, 35, 25, 53, 51};
        sort(NUMBERS);
        System.out.println(Arrays.toString(NUMBERS));
    }

    private static void sort(int[] src)
    {
        if(src != null && src.length >= 2)
        {
            for(int i = 1 ; i < src.length ; i++)
            {
                int tmp = src[i];
                int j = i - 1;
                for(; j >= 0 && src[j] > tmp; j--)
                {
                    src[j + 1] = src[j];
                }
                src[j + 1] = tmp;
            }
        }
    }
}
